﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TestPlatform.Core;
using InDB.Client;
using TestPlatform.Performer.InDB.Entities;

namespace TestPlatform.Performer.InDB
{
    public class InDBInsertPerformer : BaseInsertPerformer
    {
        public override string UnderlyinEngine { get { return "InDB"; } }

        public InDBInsertPerformer()
            : base(new InDBHelper())
        {

        }

        protected override void InsertEntity()
        {            
            using (ISession s = InDBHelper.OpenSession())
            {
                Guid id = Guid.NewGuid();

                s.Save(id, new User
                {
                    Id = id,
                    Login = id.ToString(),
                    Name = id.ToString(),
                    Posts = Enumerable.Range(0, TestConfig.InsertSubEntitiesCount)
                        .Select(i => new Post { Id = Guid.NewGuid(), Text = Guid.NewGuid().ToString() })
                        .ToList()
                });
            }
        }
    }
}
